package org.calzz.rpc.controller;

import java.util.LinkedList;
import java.util.List;

import org.calzz.jajb.annotation.JsonElement;

/**
 * @author Marek Brodziak <marek.brodziak@gmail.com>
 * @author Piotr Pejas <piotr.pejas@gmail.com>
 * @since Mar 9, 2008
 */
public class JsonProcedureDescription {
	private String name;
	private List<JsonParameterDescription> params;
	private String returnType;

	/**
	 * A String value that provides a simple name for the method.
	 * @return simple method name
	 */
	public String getName() {
		return name;
	}

	/**
	 * A String value that provides a simple name for the method.
	 * @param name simple method name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	@JsonElement("return")
	public String getReturnType() {
		return returnType;
	}

	/**
	 * @param returnType
	 */
	public void setReturnType(String returnType) {
		this.returnType = returnType;
	}

	/**
	 * An Array value whose elements are either Procedure Parameter Description
	 * objects. If an element each of uniquely describes a single parameter of
	 * the procedure. If the only description that is available of each
	 * parameter is its name, then a service MAY instead supply an Array of
	 * String elements for this member and where each element uniquely names a
	 * parameter and the parameter is assumed to be typed as "any". In either
	 * case, the elements of the array MUST be ordered after the formal argument
	 * list of the procedure being described. If this member is missing or the
	 * Null value then the procedure does not expect any parameters.
	 * @return List of Procedure Parameter Descriptions
	 */
	public List<JsonParameterDescription> getParams() {
		return params;
	}

	/**
	 * Add Procedure Parameter Description to parameter list
	 * @param param Procedure Parameter Description to add
	 */
	public void addParams(JsonParameterDescription param) {
		if (params == null) {
			params = new LinkedList<JsonParameterDescription>();
		}
		this.params.add(param);
	}

}
